<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/wipSummary.do" />
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 java.util.Calendar,
                 java.util.ArrayList,
                 com.scalar.chiptrack.adaptor.Adaptor"%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    Calendar today = Calendar.getInstance();
    String year = today.get( Calendar.YEAR )+"";
    String month = ( today.get( Calendar.MONTH ) + 1 ) +"";
%>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>
<SCRIPT language="JavaScript">
var current_month = '<%=month%>';
var current_year  = '<%=year%>';
var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}
function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function enableOrdisableDates(flag)
{
    document.wipSummaryForm.datefrom.disabled = flag;
    document.wipSummaryForm.dateto.disabled = flag;
}

function validateFromAndToDates()
{
    formdoc = document.wipSummaryForm;
    errMsg = '';
    var pa	= document.getElementById("errors")
    if(chkDate(formdoc.datefrom.value,'From-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.datefrom.focus();
        return false;
    }
    if(chkDate(formdoc.dateto.value,'To-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.dateto.focus();
        return false;
    }
    //alert("chk Date " + validateDateOut(formatDateAsMMDDYYYY(formdoc.datefrom.value),formatDateAsMMDDYYYY(formdoc.dateto.value)));
    if(formdoc.datefrom.value!='' && formdoc.dateto.value!='')
    {
        if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.datefrom.value),formatDateAsMMDDYYYY(formdoc.dateto.value)))
        {
            pa.innerHTML = "To Date cannot be less than From Date";
            formdoc.dateto.focus();
            return false;
        }
    }
    //pa.innerHTML = errMsg;
    return true;
}

function dateRange()
{
    var d = new Date();
    var day = d.getDate();
    var month = d.getMonth()+1;
    var year = d.getFullYear();
    var hour = d.getHours();
    var min = d.getMinutes();
    var sec = d.getSeconds();

    var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    var productId   = document.wipSummaryForm.product.value;
    var customerId  = document.wipSummaryForm.customer.value;
    var monthId     = document.wipSummaryForm.startMonth.value;
    var yearId      = document.wipSummaryForm.year.value;
    var month_count = document.wipSummaryForm.monthCount;
    var errors = '';

    if (monthId == '-1')
    {
        errors = errors + '<br>' + '<li> Please select the Start Month';
    }
    if (yearId == '-1')
    {
        errors = errors + '<br>' + '<li> Please select the Year';
    }
    if( month_count.value < '1')
    {
        errors = errors +'<br>' + "<li>  Please enter Valid value in Show next months";
        month_count.select();
    }
    else if( !isInteger( month_count.value ) )
    {
         errors = errors +'<br>' + "<li>  Please enter a valid Months";
         month_count.select();
    }

    if( errors == '' && ( parseInt(yearId) < parseInt(current_year) ) )
    {
         errors = errors + '<br>' + '<li> Please select the Current Year';
    }

    if(  errors == '' && ( parseInt(yearId) == parseInt(current_year) && ( parseInt(monthId) < parseInt(current_month) ) ) )
    {
        errors = errors + '<br>' + '<li> Please select the Current Month';
    }

    if(errors != '')
    {
        pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return false;
    }

    var success;
    success = true;
    /*success = validateFromAndToDates();
    if(success == false)
    {
       return false;
    } */

    if (document.wipSummaryForm.product.value=='')
        document.wipSummaryForm.prompt0.value='0';
    else
        document.wipSummaryForm.prompt0.value = document.wipSummaryForm.product.value;

    if (document.wipSummaryForm.customer.value=='')
        document.wipSummaryForm.prompt1.value='0';
    else
        document.wipSummaryForm.prompt1.value = document.wipSummaryForm.customer.value;


    /*if (period=='')
        document.wipSummaryForm.prompt2.value='MONTH';
    else
        document.wipSummaryForm.prompt2.value = period; */

    document.wipSummaryForm.prompt2.value='MONTH';

    if (document.wipSummaryForm.startMonth.value=='')
        document.wipSummaryForm.prompt3.value='0';
    else
        document.wipSummaryForm.prompt3.value = document.wipSummaryForm.startMonth.value;

    if (document.wipSummaryForm.year.value=='')
        document.wipSummaryForm.prompt4.value='0';
    else
        document.wipSummaryForm.prompt4.value = document.wipSummaryForm.year.value;

    if (document.wipSummaryForm.monthCount.value=='')
        document.wipSummaryForm.prompt5.value='0';
    else
        document.wipSummaryForm.prompt5.value = document.wipSummaryForm.monthCount.value;


    document.wipSummaryForm.prompt6.value = defaultPrompt;

    /*
    var period="";
    var cat="";
    var tp= "";

    for (counter = 0; counter < wipSummaryForm.periodically.length; counter++)
    {
        if (wipSummaryForm.periodically[counter].checked)
        {
            period = wipSummaryForm.periodically[counter].value;
        }
    }

    for (counter = 0; counter < wipSummaryForm.sourceDate.length; counter++)
    {
        if (wipSummaryForm.sourceDate[counter].checked)
        {
            cat = wipSummaryForm.sourceDate[counter].value;
        }
    }
    document.wipSummaryForm.prompt0.value='0';
    document.wipSummaryForm.prompt1.value='0';
    document.wipSummaryForm.prompt2.value='0';
    document.wipSummaryForm.prompt3.value='0';
    document.wipSummaryForm.prompt4.value= defaultPrompt;
    document.wipSummaryForm.prompt5.value='0';
    document.wipSummaryForm.prompt6.value='0';  */

    document.wipSummaryForm.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip_summary_report.rpt";
    document.wipSummaryForm.submit();
    return true;
}
</SCRIPT>
</HEAD>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%"  border="0">
<TBODY>
<TR>
<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
<!-- Side Navigation start -->
<%@ include file="/jsp/operations/reports_side_menu.jsp" %>
<!-- end of the side navigations -->
</TD>
<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>

<form name="wipSummaryForm" method="post">

    <input type="hidden" name="prompt0">
    <input type="hidden" name="prompt1">
    <input type="hidden" name="prompt2">
    <input type="hidden" name="prompt3">
    <input type="hidden" name="prompt4">
    <input type="hidden" name="prompt5">
    <input type="hidden" name="prompt6">

    <center><span class="NArialW">WIP/Inventory Vs Backlog Report</span></center>
    <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height="20">
    <table border="0" width="95%" align="right" cellspacing="0" cellpadding="0">
        <tr>
            <td colspan="6">
                <b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b>&nbsp;
            </td>
        </tr>
        <tr>
            <td width="15%"><font class="NArialL">Customer</font></td>
            <td width="20%"><font class="NArialL">
                <select size="1" name="customer" class="txfield">
                    <option value="">All Customers</option>
                    <logic:iterate id="customerSelectList" name="customerSelectList">
                        <logic:notEqual name="customerSelectList" value="null">
                            <option value = "<bean:write name="customerSelectList" property="customerId"/>" >
                                <bean:write name="customerSelectList" property="customerName"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
                </select>
            </td>
            <td width="5%">&nbsp;&nbsp;</td>
            <td width="15%">
                <font class="NArialL">Base Product<%-- <br> (<bean:message key="label.mfgPartNumber" />)--%></font>
            </td>
            <td width="30%"><font class="NArialL">
                <select size="1" name="product" class="txfield">
                    <option value="">All Products</option>
                    <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList" >
                        <logic:notEqual name="mktgPartNumberSelectList" value="null">
                            <option value="<bean:write name="mktgPartNumberSelectList" property="value"/>" >
                                <bean:write name="mktgPartNumberSelectList" property="label"/>
                            </option>
                        </logic:notEqual>
				    </logic:iterate>
                </select>
            </td>
            <td width="15%">&nbsp;</td>
        </tr>
        <tr><td colsapn="6">&nbsp;</td></tr>
        <tr>
            <td width="15%"><font class="NArialL">Start Month:</font></td>
            <td width="20%"><font class="NArialL">
                <select name="startMonth" class="txfield" disabled>
                <option value="-1">-- Select Start Month --</option>
                <logic:iterate id="monthList" name="monthList" >
                   <logic:notEqual name="monthList" value="null">
                       <option value = <bean:write name="monthList" property="value"/>
                       <logic:equal name="monthList" property="value" value="<%=month%>">selected="true"</logic:equal>>
                           <bean:write name="monthList" property="label"/>
                       </option>
                   </logic:notEqual>
                </logic:iterate>
            </select>
            </td>
            <td width="5%">&nbsp;</td>
            <td width="15%"><font class="NArialL">Year:</font></td>
            <td width="30%"><font class="NArialL">
                <select name="year" class="txfield" disabled>
                <option value="-1">-- Select --</option>
                  <logic:iterate id="years" name="years" >
                   <logic:notEqual name="years" value="null">
                       <option value = <bean:write name="years" property="value"/>
                       <logic:equal name="years" property="value" value="<%=year%>">selected="true"</logic:equal>>
                           <bean:write name="years" property="label"/>
                       </option>
                   </logic:notEqual>
                </logic:iterate>

            </select>
            </td>
            <td width="15%">&nbsp;</td>
        </tr>
        <tr><td colsapn="6">&nbsp;</td></tr>
        <tr>
            <td width="15%"><font class="NArialL">Show next:</font></td>
            <td width="20%" colspan="5" class="NArialL">
                <input type="text" readonly name="monthCount" value="6" maxlength="2" size="2" class="txfield" > weeks
            </td>
        </tr>
        <tr><td colsapn="6">&nbsp;</td></tr>
        <tr>
            <td colspan="6" align="center">
            <input type="image" onClick="javascript:return dateRange();"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Report">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:document.wipSummaryForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
            </td>
        </tr>

        <tr><td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> </tr>
        <tr><td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> </tr>
        <tr><td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> </tr>
        <tr>
         <td colspan="5" width="80%" align="left">
		 <table border="0" width="60%" align="left">
         <%
	        ArrayList adaptorList = (ArrayList) request.getAttribute ("runInfoSelectList");
	        if (adaptorList == null) adaptorList = new ArrayList();
	        if(adaptorList.size()==0)
            {
        %>
            <font class="NArialL"><font color="FF0000"><li>Adaptors Last Running Information: Not found </font></font></table>
        <%
	        }
            else
            {
        %>
        <tr  bgcolor="#993333">
            <td width="40%" align="center" ><font class="NArialL"><font color="#FFFFFF">Adaptor Name</font></td>
            <td width="40%" align="center" ><font class="NArialL"><font color="#FFFFFF">Last Updated Time</font></td>

         </tr>

        <logic:iterate id="adaptorrunInfo" name="runInfoSelectList" indexId="iterateIdx">
        <% if( Integer.parseInt( iterateIdx.toString() ) % 2 == 0 ) { %>
		<tr bgcolor='#FFFFEE'>
		<%} else { %>
		<tr bgcolor='#DEE1E2'>
		<% } %>
           <td  width="40%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="adaptorName"/></font></td>

           <td  width="40%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="adaptorRunTime"/></font></td>

           </tr>
           </logic:iterate>
           </table> <% } %> </td></tr>



    </table>
</form>

<BR><BR><BR>
</TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
